﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "IBody.h"


namespace gcmp
{
    /// \brief 布尔运算类型
    ///
    enum class BodyBooleanOperation : int32_t
    {
        /// 布尔差
        Substract,
        /// 布尔交
        Intersect,
        /// 布尔并
        Unite
    };

    /// \brief 布尔操作结果类型
    enum class BoolOperateErrorStatus : int32_t
    {
       
        Success = 0,               ///< 操作成功      
        NoTopoInformation=1,       ///< 有正常的边面，但没有拓扑信息  
        InvalidInput=2             ///< 输入无效，操作失败
    };

    /// \brief 面裁体结果
    ///
    enum class EnPlaneSplitBodyResult : int32_t
    {
        /// 失败
        SBR_Failed = 0,
        /// 成功
        SBR_Success,
        /// 没有结果
        SBR_NoResult,
        /// 和原来一致
        SBR_SameAsOriginal,
        /// 追溯信息出错
        SBR_WrongTrackingMap
    };

    /// \brief 布尔运算结果体中面的追溯数据
    ///
    struct BoolResultFaceSourceData
    {
        /// 来源的体号
        int SourceBodyIndex;

        /// 来源的面号
        int SourceFaceIndex;

        /// 是否为分裂的面
        bool isSplitted;

        ///同一条面分裂成多个面，通过orderNumber区分
        int splittedOrderNumberOnOriginalFace;

        BoolResultFaceSourceData()
        {
            SourceBodyIndex = -1;
            SourceFaceIndex = -1;
            isSplitted = false;
            splittedOrderNumberOnOriginalFace = -1;
        }

        bool BoolResultFaceSourceData::operator< (const BoolResultFaceSourceData& other) const
        {
            if (SourceBodyIndex < other.SourceBodyIndex)
                return true;
            if (SourceBodyIndex > other.SourceBodyIndex)
                return false;
            if (SourceFaceIndex < other.SourceFaceIndex)
                return true;
            if (SourceFaceIndex > other.SourceFaceIndex)
                return false;
            return false;
        }
    };

    /// \brief 布尔运算结果体中边追溯数据
    ///
    struct BoolResultEdgeSourceData
    {
        /// 来源的体号
        int SourceBodyIndex;

        /// 来源的边号
        int SourceEdgeIndex;

        /// 是否为分裂的边
        bool isSplitted;

        /// 同一条边分裂成多条边，通过orderNumber区分
        int splittedOrderNumberOnOriginalEdge;

        /// 是否为新产生的边
        bool isNewlyCreated;

        BoolResultEdgeSourceData()
        {
            SourceBodyIndex = -1;
            SourceEdgeIndex = -1;
            isSplitted = false;
            splittedOrderNumberOnOriginalEdge = -1;
            isNewlyCreated = false;
        }

        bool BoolResultEdgeSourceData::operator< (const BoolResultEdgeSourceData& other) const
        {
            if (SourceBodyIndex < other.SourceBodyIndex)
                return true;
            if (SourceBodyIndex > other.SourceBodyIndex)
                return false;
            if (SourceEdgeIndex < other.SourceEdgeIndex)
                return true;
            if (SourceEdgeIndex > other.SourceEdgeIndex)
                return false;
            return false;
        }
    };

    /// \brief 消隐边的追溯数据
    ///
    struct HiddenEdgeSourceData
    {
        /// 来源的边号
        int sourceEdgeIndex;

        /// 是否是从一条边上split生成的
        bool isSplitFromEdge;  
    };
}